<template>
	<div>
		<!-- 取消调度提示窗 -->
		<uni-popup ref="cancelDispatchDialog" type="dialog">
			<uni-popup-dialog type="info" cancelText="关闭" confirmText="确认" title="取消调度"
				@confirm="cancelDispatchDialogConfirm">
				<scroll-view scroll-top="0" scroll-y="true" style="height: 200px;">
					<view style="display: flex;flex-direction: column;width: 100%;">
						<view style="display: flex;">
							<text style="width: 75px;">发车批次：</text>
							<text style="font-weight: bold;margin-left: 20px;">{{formData.scheduleVo.scheduleNo}}</text>
						</view>
						<view v-if="formData.scheduleVo.carrierVo" style="display: flex;">
							<text style="width: 75px;">承运方：</text>
							<text style="margin-left: 20px;">{{formData.scheduleVo.carrierVo.carrierName}}</text>
						</view>
						<view style="display: flex;">
							<text style="width: 75px;">车型：</text>
							<text style="margin-left: 20px;">{{carType_[formData.scheduleVo.carVo.carType]}}</text>
						</view>
						<view style="display: flex;">
							<text style="width: 75px;">车牌号：</text>
							<text style="margin-left: 20px;">{{formData.scheduleVo.carVo.licensePlate}}</text>
						</view>
						<!-- <view style="display: flex;">
							<text style="width: 75px;">车辆定位：</text>
							<text style="margin-left: 20px;">{{formData.scheduleVo.scheduleNo}}</text>
						</view> -->
						<view style="display: flex;">
							<text style="width: 75px;">司机：</text>
							<text style="margin-left: 20px;">{{formData.scheduleVo.driverVo.driverName}}</text>
						</view>
						<view style="display: flex;">
							<text style="width: 75px;">司机电话：</text>
							<text style="margin-left: 20px;">{{formData.scheduleVo.driverVo.phoneNumber}}</text>
						</view>
						<view style="display: flex;margin-top: 10px;color: #bf5f09;">
							<text>*确认取消当前运单{{formData.scheduleNo}}调度车次</text>
						</view>
					</view>
				</scroll-view>
			</uni-popup-dialog>
		</uni-popup>
	</div>
</template>

<script>
	import {
		putScheduleStatus,
	} from '@/api/system/waybill.js'
	export default {
		props: {
			data: {
				type: Object,
				default: {}
			},
			waybillId:{
				type: String,
				default:''
			},
			carType_:{
				type: Array,
				default:[]
			},
		},
		data() {
			return {
				formData:{
					scheduleVo:{}
				},
			}
		},
		watch: {
			data: {
			　　handler(newValue, oldValue) {
			　　　	this.formData=newValue
			　　},
			　　deep: true
			},
		},
		methods: {
			//取消调度
			cancelDispatch() {
				this.$refs.cancelDispatchDialog.open()
			},
			//确认取消调度
			cancelDispatchDialogConfirm() {
				uni.showLoading({
					title: '正在取消调度...',
				})
				putScheduleStatus(this.waybillId,440).then(res => {
					uni.hideLoading()
					if (res.code == '200') {
						uni.showToast({
							title: '取消调度成功',
							icon: 'none'
						})
						this.$parent.init()  //调用父组件的init函数,重新加载数据
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}		
				})
			},
		},
	}
</script>

<style scoped>

</style>